using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Specialized;
using System.Web;

namespace Pitoshka.Web.UrlRewriter
{
    /// <summary>
    /// This class contains context information for rewrite module.
    /// </summary>
    public class RewriteContext
    {

        public static RewriteContext Current
        {
            get {
            
            if(HttpContext.Current.Items.Contains("RewriteContextInfo"))
                return (RewriteContext)HttpContext.Current.Items["RewriteContextInfo"];
            else
                return new RewriteContext();
            }
        }

        public RewriteContext()
        {
            _Params = new NameValueCollection();
            _InitialUrl = String.Empty;
        }

        public RewriteContext(NameValueCollection param, string url)
        {
            _InitialUrl = url;
            _Params = new NameValueCollection(param); // copy collection
            
        }

        private NameValueCollection _Params;

        public NameValueCollection Params
        {
            get { return _Params; }
            set { _Params = value; }
        }

        private string _InitialUrl;

        public string InitialUrl
        {
            get { return _InitialUrl; }
            set { _InitialUrl = value; }
        }
    }
}
